const express = require('express');
const stu = require('./mongo/testSchema.js');
const bodyParser = require('body-parser');
const app = express();
app.listen(5566,() => {
    console.log(`server started on port 5566`);
});
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(bodyParser.raw());

app.get('/user',(req,res) => {
    stu.find({}).then(docs => {
	    res.send(docs)
    })
});

app.post('/user',(req,res) => {
    let {name , age} = {...req.body}
    let nstu = new stu({name,age});
    nstu.save().then(doc => {
	    res.send("ok")
    })
})
